Previous topicNext topic
Help > Keyword Reference >
SETEOF statement

Purpose

Truncate or extend an open file to its current file pointer (read/write) position.

Syntax

SETEOF [#] filenum&

Remarks

SETEOF will truncate or extend an open file to its current file pointer (read/write) position, which may be set explicitly with the SEEK statement.

Unlike 16-bit Windows and DOS BASIC, Win32 will not truncate a file if you simply write an empty string to it, so the SETEOF statement is provided to cater for this need.

See also

CLOSE, FILEATTR, FLUSH, OPEN, SEEK function, SEEK statement

Example

FUNCTION PBMAIN

 OPEN "Temp.dat" FOR BINARY AS #1 BASE = 1

 A$ = SPACE$(50)

 PUT$ #1, A$

 ' File is now 50 bytes

 SEEK #1, 15

 ' Move to the 15th byte and truncate there

 SETEOF #1

 ' File is now 14 bytes

 CLOSE #1

END FUNCTION